﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CheckedListBox
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            checkedListBox1.Items.Add("星期一");
            checkedListBox1.Items.Add("星期二");
            checkedListBox1.Items.Add("星期三");
            checkedListBox1.Items.Add("星期四");
            checkedListBox1.Items.Add("星期五");
            checkedListBox1.Items.Add("星期六");
            checkedListBox1.Items.Add("星期日");
        }

        private void LxiangR_Click(object sender, EventArgs e)
        {
            foreach(object o in checkedListBox1.CheckedItems)
            {
                checkedListBox2.Items.Add(o);
            }
            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                if (checkedListBox1.CheckedItems.Contains(checkedListBox1.Items[i]))
                {
                    checkedListBox3.Items.Add(checkedListBox1.Items[i].ToString() + "被移至右侧");
                    checkedListBox1.Items.Remove(checkedListBox1.Items[i]);
                }
            }
        }

        private void allR_Click(object sender, EventArgs e)
        {
            foreach (object o in checkedListBox1.Items)
            {
                checkedListBox2.Items.Add(o);
            }
            checkedListBox1.Items.Clear();
            checkedListBox3.Items.Add("左侧全部移到右侧");
        }

        private void RxiangL_Click(object sender, EventArgs e)
        {
            foreach (object o in checkedListBox2.CheckedItems)
            {
                checkedListBox1.Items.Add(o);
            }
            for (int i = 0; i < checkedListBox2.Items.Count; i++)
            {
                if (checkedListBox2.CheckedItems.Contains(checkedListBox2.Items[i]))
                {
                    checkedListBox3.Items.Add(checkedListBox1.Items[i].ToString() + "被移至左侧");
                    checkedListBox2.Items.Remove(checkedListBox2.Items[i]);
                }
            }
        }

        private void allL_Click(object sender, EventArgs e)
        {
            foreach (object o in checkedListBox2.Items)
            {
                checkedListBox1.Items.Add(o);
            }
            checkedListBox2.Items.Clear();
            checkedListBox3.Items.Add("右侧全部移到左侧");
        }
    }
}
